When we want to have more than one page on a single form then we use Tab Control. Here I have used Tab Control with two pages, tabPage1 and tabPage2. TabPage1 contains Radio Buttons while tabPage2 contains TreeView.
You can simply drag and drop Tab Control from tool box of VisualStudio.
Coding of controls present in tabPage1.
privatevoid rdoRed_Click(object sender, EventArgs e)
{
this.BackColor = Color.Red;
gbColor.ForeColor = Color.Red;
btnDefault.ForeColor = Color.Black;
}
privatevoid rdoBlue_Click(object sender, EventArgs e)
{
this.BackColor = Color.Blue;
gbColor.ForeColor = Color.Blue;
btnDefault.ForeColor = Color.Black;
}
privatevoid btnDefault_Click(object sender, EventArgs e)
{
this.BackColor = DefaultBackColor;
gbColor.ForeColor = DefaultForeColor;
rdoRed.Checked = false;
rdoBlue.Checked = false;
rdoGreen.Checked = false;
}
privatevoid rdoGreen_Click(object sender, EventArgs e)
{
this.BackColor = Color.Green;
gbColor.ForeColor = Color.Green;
btnDefault.ForeColor = Color.Black;
}
Coding of controls on tabPage2.
privatevoid treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
TreeNode nName = e.Node;
string webPage = "";
webPage = (string)nName.Tag;
if (webPage != "")
{
webBrowser1.Navigate(webPage);
}
}
Manish Kumar
29-Jun-2017It was really helpful to read this post.